﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MicroBlogClient
{
    /// <summary>
    /// Interaction logic for UCPager.xaml
    /// </summary>
    public partial class UCPager : UserControl
    {
        public UCPager()
        {
            InitializeComponent();
            DataContext = this;
        }

        #region Event
        public static readonly RoutedEvent OnFirstPageClickEvent = EventManager.RegisterRoutedEvent(
           "OnFirstPageClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UCPager));

        public event RoutedEventHandler OnFirstPageClick
        {
            add { AddHandler(OnFirstPageClickEvent, value); }
            remove { RemoveHandler(OnFirstPageClickEvent, value); }
        }

        public static readonly RoutedEvent OnNextPageClickEvent = EventManager.RegisterRoutedEvent(
            "OnNextPageClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UCPager));

        public event RoutedEventHandler OnNextPageClick
        {
            add { AddHandler(OnNextPageClickEvent, value); }
            remove { RemoveHandler(OnNextPageClickEvent, value); }
        }

        public static readonly RoutedEvent OnPreviousePageClickEvent = EventManager.RegisterRoutedEvent(
           "OnPreviousePageClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UCPager));

        public event RoutedEventHandler OnPreviousePage
        {
            add { AddHandler(OnPreviousePageClickEvent, value); }
            remove { RemoveHandler(OnPreviousePageClickEvent, value); }
        }
        #endregion

        #region Dependency Property
        public bool CanPreviousePageClick
        {
            get { return (bool)GetValue(CanPreviousePageClickProperty); }
            set { SetValue(CanPreviousePageClickProperty, value); }
        }

        // Using a DependencyProperty as the backing store for CanPreviousePageClick.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty CanPreviousePageClickProperty =
            DependencyProperty.Register("CanPreviousePageClick", typeof(bool), typeof(UCPager), new UIPropertyMetadata(false));


        public bool CanNextPageClick
        {
            get { return (bool)GetValue(CanNextPageClickProperty); }
            set { SetValue(CanNextPageClickProperty, value); }
        }

        // Using a DependencyProperty as the backing store for CanNextPageClick.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty CanNextPageClickProperty =
            DependencyProperty.Register("CanNextPageClick", typeof(bool), typeof(UCPager), new UIPropertyMetadata(true));

        #endregion

        private void linkFirstPage_Click(object sender, RoutedEventArgs e)
        {
            RaiseEvent(new RoutedEventArgs(OnFirstPageClickEvent));
        }

        private void linkPreviousePage_Click(object sender, RoutedEventArgs e)
        {
            RaiseEvent(new RoutedEventArgs(OnPreviousePageClickEvent));
        }

        private void linkNextPage_Click(object sender, RoutedEventArgs e)
        {
            RaiseEvent(new RoutedEventArgs(OnNextPageClickEvent));
        }
    }
}
